<template>
    <div>
        <el-form inline :model="query" class="demo-form-inline">
            <el-form-item label="审批人">
                <el-input v-model="query.user" placeholder="审批人"></el-input>
            </el-form-item>
            <el-form-item label="活动区域">
                <el-select v-model="query.region" placeholder="活动区域">
                    <el-option label="区域一" value="shanghai"></el-option>
                    <el-option label="区域二" value="beijing"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="handleQuery">查询</el-button>
                <el-button type="success" @click="handleCreate">新建</el-button>
            </el-form-item>
            <el-row>
                <el-form-item>
                    <el-button type="warning">帐号类型管理</el-button>
                </el-form-item>
            </el-row>
        </el-form>
        
        <TablePage ref="tablePage" :fetch="fetchTable" :params="query">
            <el-table-column fixed align="center" type="index" width="50"></el-table-column>
            <el-table-column prop="date" align="center" label="日期" width="120"></el-table-column>
            <el-table-column prop="name" align="center" label="姓名" width="120"></el-table-column>
            <el-table-column prop="address" align="center" label="地址" width="120"></el-table-column>
            <el-table-column prop="address" align="center" label="地址" width="120"></el-table-column>
            <el-table-column prop="address" align="center" label="地址" width="120"></el-table-column>
            <el-table-column prop="address" align="center" label="地址" width="120"></el-table-column>
            <el-table-column prop="address" align="center" label="地址" width="120"></el-table-column>
            <el-table-column prop="address" align="center" label="地址" width="120"></el-table-column>
            <el-table-column prop="address" align="center" label="地址" width="120"></el-table-column>
            <el-table-column prop="address" align="center" label="地址" width="120"></el-table-column>
            <el-table-column prop="address" align="center" label="地址" width="120"></el-table-column>
            <el-table-column fixed="right" align="center" label="操作" width="140">
                <template slot-scope="{row}">
                    <el-button type="text" size="small">查看</el-button>
                    <el-button type="text" size="small" @click="handleCreate(row.id)">编辑</el-button>
                    <el-button type="text" size="small" class="danger">删除</el-button>
                </template>
            </el-table-column>
        </TablePage>

        <Dialog
            title="创建帐号"
            :dialogConfig="dialogConfig"
            v-on:mainDialogOpeartion="mainDialogOpeartion"
            v-on:innerDialogOpeartion="innerDialogOpeartion"
        >
            <div slot="mainCont">
                <el-form :model="form">
                    <p v-show="dialogConfig.id===''">用户使用帐号名称进行登录，默认密码为123456</p>
                    <el-form-item label="账户名称">
                        <el-input v-model="form.name" class="normal"></el-input>
                    </el-form-item>
                    <el-form-item label="帐号类型">
                        <el-select v-model="form.region" placeholder="请选择">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="关联商户">
                        <el-select v-model="form.region" placeholder="请选择">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="账户状态">
                        <el-select v-model="form.region" placeholder="请选择">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="" v-show="dialogConfig.id!==''">
                        <el-button type="warning" @click="dialogConfig.innerVisible=true">重置密码</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </Dialog>
    </div>
</template>
<script>

import TablePage from '@/components/TablePage'
import Dialog from '@/components/Dialog'
export default {
    components: { TablePage, Dialog },
    data() {
        return {
            query: {
                user: '',
                region: ''
            },
            form: {
                name: '',
                type: '',
                relational: '',
                status: ''
            },
            dialogConfig: {
                mainVisible: false,
                id: '',
                innerVisible: false
            },
        }
    },
    methods: {
        fetchTable(pramas) {
            return [
                {   
                    id: 1,
                    date: '2016-05-02',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1518 弄'
                }, {
                    id: 2,
                    date: '2016-05-04',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1517 弄'
                }, {
                    id: 3,
                    date: '2016-05-01',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1519 弄'
                }, {
                    id: 4,
                    date: '2016-05-03',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1516 弄'
                }
            ]
        },
        handleQuery() {
            this.fetchTable(this.query);
        },
        handleCreate(id) {
            const _id = id.target ? '' : id;
            this.dialogConfig.id = _id;
            this.dialogConfig.mainVisible = true;
            if (_id) {
                this.dialogConfig.textTip = false;
            }
        },
        handleReset() {
            this.dialogConfig.innerVisible = false;
            this.dialogConfig.mainVisible = false;
        },
        mainDialogOpeartion(isClose) {
            this.dialogConfig.mainVisible = isClose;
        },
        innerDialogOpeartion(isClose) {
            this.dialogConfig.innerVisible = isClose;
        }
    }
}
</script>
<style lang="less">

</style>
